package com.yuetong.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yuetong.common.annotation.Log;
import com.yuetong.common.core.controller.BaseController;
import com.yuetong.common.core.domain.AjaxResult;
import com.yuetong.common.enums.BusinessType;
import com.yuetong.business.domain.YtElevatorModels;
import com.yuetong.business.service.IYtElevatorModelsService;
import com.yuetong.common.utils.poi.ExcelUtil;
import com.yuetong.common.core.page.TableDataInfo;

/**
 * 电梯型号管理Controller
 * 
 * @author  卓晓君
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/business/models")
public class YtElevatorModelsController extends BaseController
{
    @Autowired
    private IYtElevatorModelsService ytElevatorModelsService;

    /**
     * 查询电梯型号管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:models:list')")
    @GetMapping("/list")
    public TableDataInfo list(YtElevatorModels ytElevatorModels)
    {
        startPage();
        List<YtElevatorModels> list = ytElevatorModelsService.selectYtElevatorModelsList(ytElevatorModels);
        return getDataTable(list);
    }

    /**
     * 导出电梯型号管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:models:export')")
    @Log(title = "电梯型号管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YtElevatorModels ytElevatorModels)
    {
        List<YtElevatorModels> list = ytElevatorModelsService.selectYtElevatorModelsList(ytElevatorModels);
        ExcelUtil<YtElevatorModels> util = new ExcelUtil<YtElevatorModels>(YtElevatorModels.class);
        util.exportExcel(response, list, "电梯型号管理数据");
    }

    /**
     * 获取电梯型号管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:models:query')")
    @GetMapping(value = "/{modelId}")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
    {
        return success(ytElevatorModelsService.selectYtElevatorModelsByModelId(modelId));
    }

    /**
     * 新增电梯型号管理
     */
    @PreAuthorize("@ss.hasPermi('business:models:add')")
    @Log(title = "电梯型号管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YtElevatorModels ytElevatorModels)
    {
        return toAjax(ytElevatorModelsService.insertYtElevatorModels(ytElevatorModels));
    }

    /**
     * 修改电梯型号管理
     */
    @PreAuthorize("@ss.hasPermi('business:models:edit')")
    @Log(title = "电梯型号管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YtElevatorModels ytElevatorModels)
    {
        return toAjax(ytElevatorModelsService.updateYtElevatorModels(ytElevatorModels));
    }

    /**
     * 删除电梯型号管理
     */
    @PreAuthorize("@ss.hasPermi('business:models:remove')")
    @Log(title = "电梯型号管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modelIds}")
    public AjaxResult remove(@PathVariable Long[] modelIds)
    {
        return toAjax(ytElevatorModelsService.deleteYtElevatorModelsByModelIds(modelIds));
    }
}
